Applies an accumulator function over a view.

Namespace:  C1.LiveLinq
Assembly:  C1.Silverlight.LiveLinq (in C1.Silverlight.LiveLinq.dll)

Syntax

C#
public static AggregationView<TSource, TSource> LiveAggregate<TSource>(
	this View<TSource> source,
	Expression<Func<TSource, TSource, TSource>> funcAdd,
	Expression<Func<TSource, TSource, TSource>> funcRemove,
	Expression<Func<TSource, TSource, bool>> funcRemoveDefined
)
Visual Basic
<ExtensionAttribute> _
Public Shared Function LiveAggregate(Of TSource) ( _
	source As View(Of TSource), _
	funcAdd As Expression(Of Func(Of TSource, TSource, TSource)), _
	funcRemove As Expression(Of Func(Of TSource, TSource, TSource)), _
	funcRemoveDefined As Expression(Of Func(Of TSource, TSource, Boolean)) _
) As AggregationView(Of TSource, TSource)

Parameters

source
Type: C1.LiveLinq.LiveViews..::..View<(Of <(<'TSource>)>)>
A view to aggregate over.
funcAdd
Type: System.Linq.Expressions..::..Expression<(Of <(<'Func<(Of <(<'TSource, TSource, TSource>)>)>>)>)>
An accumulator function to be invoked on each element that is added to the source view.
funcRemove
Type: System.Linq.Expressions..::..Expression<(Of <(<'Func<(Of <(<'TSource, TSource, TSource>)>)>>)>)>
A function to be applied to the accumulated value and to an element to obtain the changed accumulated value, when an element is removed from the source view.
funcRemoveDefined
Type: System.Linq.Expressions..::..Expression<(Of <(<'Func<(Of <(<'TSource, TSource, Boolean>)>)>>)>)>
A function used to determine whether funcRemove must be applied when an element is removed from the source view, or the accumulated value is not affected by its removal.

Type Parameters

TSource
The type of the elements of source.

Return Value

A view representing the final accumulator value.

Remarks

It is possible to use standard LINQ query operator Aggregate instead of LiveAggregate. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Aggregate will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAggregate will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.

See Also